package com.example.skillcinema.ui.screens.main.viewmodels

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.skillcinema.db.models.Season
import com.example.skillcinema.db.repositories.FilmForPreviewRepository
import com.example.skillcinema.db.responses.SeasonResponse
import dagger.hilt.android.lifecycle.HiltViewModel
import jakarta.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

@HiltViewModel
class SeasonDetailsViewModel @Inject constructor(val repository: FilmForPreviewRepository) :
    ViewModel() {
    private val _seasonInfoStateFlow: MutableStateFlow<List<Season>> =
        MutableStateFlow<List<Season>>(listOf())
    val seasonInfo = _seasonInfoStateFlow.asStateFlow()
    fun loadData(id: Int) {
        viewModelScope.launch {
            _seasonInfoStateFlow.value = repository.getSeasonsForPreview(id)
        }
    }
}